<template>
    <div class="swHomeTask-page" data-page="swHomeTask">
        <div class="sw-card">
            <div class="sw-card__head">
                <div class="sw-card__title">维保任务</div>
            </div>
            <div class="sw-card__body is-task wbtask1">
                <div class="task-title">
                    <div class="task-icon task-icon--xuncha"></div>
                    <div class="task-title">维保巡查</div>
                </div>
                <div class="task-count">
                    <div>
                        <span class="task-count__num">0</span>未指派任务数
                    </div>
                    <div>
                        <span class="task-count__num">0</span>待完成任务数
                    </div>
                </div>
            </div>
            <div class="sw-card__body is-task wbtask2">
                <div class="task-title">
                    <div class="task-icon task-icon--baoyang"></div>
                    <div class="task-title">保养</div>
                </div>
                <div class="task-count">
                    <div>
                        <span class="task-count__num">0</span>未指派任务数
                    </div>
                    <div>
                        <span class="task-count__num">0</span>待完成任务数
                    </div>
                </div>
            </div>
            <div class="sw-card__body is-task wbtask3">
                <div class="task-title">
                    <div class="task-icon task-icon--dandian"></div>
                    <div class="task-title">单点测试</div>
                </div>
                <div class="task-count">
                    <div>
                        <span class="task-count__num">0</span>未指派任务数
                    </div>
                    <div>
                        <span class="task-count__num">0</span>待完成任务数
                    </div>
                </div>
            </div>
            <div class="sw-card__body is-task wbtask4">
                <div class="task-title">
                    <div class="task-icon task-icon--liandong"></div>
                    <div class="task-title">联动测试</div>
                </div>
                <div class="task-count">
                    <div>
                        <span class="task-count__num">0</span>未指派任务数
                    </div>
                    <div>
                        <span class="task-count__num">0</span>待完成任务数
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<style scoped></style>
<script>
    return {
        data:function () {
            return{
            }
        },
        methods: {
            getData:function(){
                var self=this
                Dao.getMaintainListForAppSw({
                    orgId:single_Orgid_wbdw,
                },function(data){
                    // data=[
                    //     {name:'月度维保完成度',id:1,value:80,total:80},
                    //     {name:'季度维保完成度',id:2,value:90,total:100},
                    //     {name:'年度维保完成度',id:3,value:50,total:100}
                    // ]
                    if(data&&data.length>0){
                        $(".swHomeTask-page").show();
                        for(var i=0;i<data.length;i++){
                            var o=data[i]
                            var $nums=jQuery('.wbtask'+o.type+' .task-count__num')
                            $nums[0].innerText=o.notDis||0
                            $nums[1].innerText=o.startNotFin||0
                        }
                    }else{
                        $(".swHomeTask-page").hide();
                    }
                });
            },
            bindEvents(){
                jQuery('.wbtask1').off().click(function(){
                    app.router.navigate(`/maintainInspect/1/${single_Orgid_wbdw}/`);
                })
                jQuery('.wbtask2').off().click(function(){
                    app.router.navigate(`/maintain/2/${single_Orgid_wbdw}/`);
                })
                jQuery('.wbtask3').off().click(function(){
                    app.router.navigate(`/singleTest/1/${single_Orgid_wbdw}/`);
                })
                jQuery('.wbtask4').off().click(function(){
                    app.router.navigate(`/linkTest/1/${single_Orgid_wbdw}/`);
                })
            }
        },
        on: {
            pageAfterIn: function (e, page) {
                var self = this;
                self.bindEvents()
                self.getData();
            }
        }
    }
</script>